package org.meb.speedway.web.log;

import java.io.Serializable;
import java.util.Arrays;

import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
public class Log implements Serializable {

	private static final long serialVersionUID = 5482135239851071290L;

	private LogEntry[] entries;

	public Log(String text, String entryDelim, String messageDelim) {
		String[] texts = text.split(entryDelim);
		entries = new LogEntry[texts.length];
		for (int i = 0; i < texts.length; i++) {
			String[] messages = texts[i].split(messageDelim);
			String[] detailMessages = Arrays.copyOfRange(messages, 1, messages.length);
			entries[i] = new LogEntry(messages[0], detailMessages);
		}
	}
}
